<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="zh">
<!--<![endif]-->
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>
<head>
    <meta charset="utf-8" />
    <title>保险代理后台管理系统</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <!-- ================== BEGIN BASE CSS STYLE ================== -->
    <jsp:include page="../common/header.jsp"/>
    <%@include file="../common/taglib.jsp"%>
    <!-- ================== END BASE CSS STYLE ================== -->

</head>
<body>
<!-- begin #page-loader -->
<div id="page-loader" class="fade in"><span class="spinner"></span></div>
<!-- end #page-loader -->

<!-- begin #page-container -->
<div id="page-container" class="fade page-sidebar-fixed page-header-fixed">
    <jsp:include page="../common/top.jsp"/>

    <!-- begin #sidebar -->
    <jsp:include page="../common/sitebar.jsp"/>
    <div class="sidebar-bg"></div>
    <!-- end #sidebar -->

    <!-- begin #content -->
    <div id="content" class="content">
        <div class="row">
            <!-- begin col-6 -->
            <div class="col-md-12">

                <ul class="nav nav-tabs">
                    <li class=""><a href="##default-tab-2" data-toggle="tab" onclick="javascript:history.back(-1);">保险公司列表</a></li>
                    <shiro:hasPermission name="保险公司管理-新增">
                        <c:choose>
                            <c:when test="${insurer.tid!=null}">
                                <li class="active"><a href="#default-tab-1" data-toggle="tab">编辑保险公司</a></li>
                            </c:when>
                            <c:otherwise>
                                <li class="active"><a href="#default-tab-1" data-toggle="tab">新建保险公司</a></li>
                            </c:otherwise>
                        </c:choose>
                    </shiro:hasPermission>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane fade active in" id="default-tab-1">
                        <div class="panel panel-inverse" data-sortable-id="form-validation-1">

                            <div class="panel-body panel-form">
                                <form role="form" action="/insurer/add" method="post" class="form-horizontal form-bordered" data-parsley-validate="true">
                                    <input type="hidden" class="form-control" name="tid" value="${insurer.tid}">
                                    <div class="form-group">
                                        <label class="control-label col-md-4 col-sm-4">保险公司名称:</label>
                                        <div class="col-md-6 col-sm-6">
                                            <input class="form-control" type="text" id="name" name="name" value="${insurer.name}" data-parsley-required="true"
                                                   data-parsley-required-message="保险公司名称不能为空"  data-parsley-minlength="4" data-parsley-minlength-message="保险公司最短为4个字符" data-parsley-maxlength="20"  data-parsley-maxlength-message="保险公司最长为20个字符"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-4 col-sm-4">所属地区:</label>
                                        <div class="col-md-6 col-sm-6">
                                            <input class="form-control" type="text" id="area" name="area" value="${insurer.area}"
                                                   data-parsley-minlength="4" data-parsley-minlength-message="所属地区最短为4个字符" data-parsley-maxlength="50"  data-parsley-maxlength-message="所属地区最长为50个字符"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-4 col-sm-4">账户开户名:</label>
                                        <div class="col-md-6 col-sm-6">
                                            <input class="form-control" type="text" id="accountName" name="accountName" value="${insurer.accountName}" data-parsley-required="true"
                                                   data-parsley-required-message="账户开户名不能为空" data-parsley-maxlength="20"  data-parsley-maxlength-message="账户开户名最长为20个字符"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-4 col-sm-4">银行账号:</label>
                                        <div class="col-md-6 col-sm-6">
                                            <input class="form-control" type="text" maxlength="30" id="accountNumber" name="accountNumber" value="${insurer.accountNumber}" data-parsley-type="number" data-parsley-required="true"
                                                   data-parsley-required-message="银行账号不能为空" data-parsley-minlength="16" data-parsley-minlength-message="银行账号最短为16位"  data-parsley-maxlength="20"  data-parsley-maxlength-message="银行账号最长为20位"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-4 col-sm-4">所属银行:</label>
                                        <div class="col-md-6 col-sm-6">
                                            <input class="form-control" type="text" maxlength="30" id="bankName" name="bankName" value="${insurer.bankName}" data-parsley-required="true"
                                                   data-parsley-required-message="所属银行不能为空"  data-parsley-maxlength="30"  data-parsley-maxlength-message="所属银行最长为30个字符"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-4 col-sm-4">开户支行:</label>
                                        <div class="col-md-6 col-sm-6">
                                            <input class="form-control" type="text" id="bankBranch" name="bankBranch" value="${insurer.bankBranch}" data-parsley-required="true"
                                                   data-parsley-required-message="开户支行不能为空"  data-parsley-maxlength="50"  data-parsley-maxlength-message="开户支行最长为50位"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-4 col-sm-4">固定保单号:</label>
                                        <div class="col-md-6 col-sm-6">
                                            <input class="form-control" type="text" id="policyNumber" name="policyNumber" value="${insurer.policyNumber}" data-parsley-required="true"
                                                   data-parsley-required-message="固定保单号不能为空"  data-parsley-maxlength="30"  data-parsley-maxlength-message="固定保单号最长为30位"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-4 col-sm-4">联系人:</label>
                                        <div class="col-md-6 col-sm-6">
                                            <input class="form-control" type="text" id="contacts" name="contacts" value="${insurer.contacts}" data-parsley-required="true"
                                                   data-parsley-required-message="联系人不能为空"  data-parsley-maxlength="24"  data-parsley-maxlength-message="联系人最长为24个字符"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-4 col-sm-4">联系人电话:</label>
                                        <div class="col-md-6 col-sm-6">
                                            <input class="form-control" type="text" maxlength="20" id="phone" name="phone" value="${insurer.phone}" data-parsley-required="true"
                                                   data-parsley-required-message="联系人电话不能为空"  data-parsley-maxlength="20"  data-parsley-maxlength-message="联系人电话最长为20位"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-4 col-sm-4">业务员:</label>
                                        <div class="col-md-6 col-sm-6">
                                            <input type="hidden" class="form-control" id="userName" name="userName" value="${insurer.userName}">
                                            <select class="form-control input-lg" id="userId" name="userId" onchange="setName();" placeholder="业务员"  data-parsley-required="true"
                                                    data-parsley-required-message="业务员不能为空">
                                                <option value="">请选择</option>
                                                <c:forEach items="${list}" var="us">
                                                    <option value="${us.tid}"<c:if test="${ us.tid == insurer.userId}"> selected="selected" </c:if>>${us.username}</option>
                                                </c:forEach>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-4 col-sm-4"></label>
                                        <div class="col-md-6 col-sm-6">
                                            <button type="button" onClick="goBack()" class="btn btn-default">取  消</button>
                                            <button type="submit" class="btn btn-primary">提  交</button>
                                        </div>

                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="tab-pane fade" id="default-tab-2">
                    <p>
                        <i class="fa fa-spinner fa-stack-2x"></i>
                        &nbsp;
                    </p>
                </div>

                <div class="modal fade" id="modal-subInfo">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                <h4 class="modal-title">提示</h4>
                            </div>
                            <div id="showSubInfo" class="modal-body">
                                当前填写内容未提交，确认取消？
                            </div>
                            <div class="modal-footer">
                                <a href="javascript:;" id="subButtonNo" class="btn btn-sm btn-white" data-dismiss="modal">取消</a>
                                <a href="javascript:;" id="subButtonYes" class="btn btn-sm btn-success">确定</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- end col-6 -->
        </div>

    </div>
    <!-- end #content -->

    <!-- begin scroll to top btn -->
    <a href="javascript:;" class="btn btn-icon btn-circle btn-success btn-scroll-to-top fade" data-click="scroll-top"><i class="fa fa-angle-up"></i></a>
    <!-- end scroll to top btn -->
</div>
<!-- end page container -->
<jsp:include page="../common/footer.jsp"/>


<!-- ================== END PAGE LEVEL JS ================== -->

<script>
    $(document).ready(function() {
        App.init();
        Dashboard.init();
    });
    function setName() {
        var userId = $("#userId").val();
        var options=$("#userId option:selected");
        var userName = options.text();
        if(""==userId){
            userName = "";
        }
        $("#userName").val(userName);
    }
    function goBack(){
        $("#showSubInfo").html(" 当前填写内容未提交，确认取消？");
        $("#subButtonYes").attr("onclick","javascript:history.back(-1);");
        $("#modal-subInfo").modal('show');
    }
</script>

</body>
</html>
